# -*- coding: utf-8 -*-
# @Time    : 2021/1/14 10:43
# @Author  : DuJiabao
# @Project : BaoZaiFanYiWuJianCe
# @FileName: GlobalStatement.py
# @Software: PyCharm
# @Desc    :
from queue import Queue
from enum import Enum
import threading
import datetime


def lutous_states_init(num: int) -> tuple:
    """
    炉头状态初始化
    :param num:
    :return:
    """
    lutou_yiwu_states = {}
    lutou_open_states = {}
    for i in range(num):
        lutou_yiwu_states[i] = lutou_yiwu_state_t.unknown
        lutou_open_states[i] = lutou_open_state_t.closed
    return lutou_yiwu_states, lutou_open_states


def put_message(message):
    """
    将消息放入打印日志的消息队列中
    :param message:
    :return:
    """
    msg_out = str(datetime.datetime.now()) + ': ' + message
    log_message_queue.put(msg_out)


# 线程安全，无需同步
# 识别线程 -> 通信线程
update_lutou_yiwu_state_queue = Queue(1)  # 识别照片的线程，在更新了炉头信息之后，发一个消息给消息队列，通信的线程予以回复
# 通信线程 -> 拍照线程
update_lutou_open_state_queue = Queue(1)  # 收到查询炉头的开合状态的信息之后，通信的线程发一个消息给消息队列，获取照片的线程收到之后，进行拍照
# 拍照线程 -> 识别线程
photo_queue = Queue(1)  # 获取照片的线程获取照片之后，发一个消息给队列，识别的线程收到消息之后，执行识别操作

lutou_num = 24
lutou_yiwu_state_t = Enum("lutou_yiwu_state_t", ("unknown", "empty", "exist"))  # 炉头的是否存在异物的三种状态
lutou_open_state_t = Enum("lutou_open_state_t", ("open", "closed"))  # 炉头的开关状态
lutou_yiwu_states, lutou_open_states = lutous_states_init(lutou_num)

log_message_queue = Queue(5)  # 打印消息的队列
log_dir = "./log"

if __name__ == "__main__":
    pass
